#用于统计算法涉及运算操作

# 操作计数器
shift_count = 0
mul_count = 0
div_count = 0
index_count = 0
float_count = 0
lookup_count = 0

def bit_shift(val, direction, n):
    global shift_count
    shift_count += 1
    return val << n if direction == 'left' else val >> n

def multiply(a, b):
    global mul_count
    mul_count += 1
    return a * b

def divide(a, b):
    global div_count
    div_count += 1
    return a / b

def index(a, b):
    global index_count
    index_count += 1
    return a ** b 

def float_op(a, b):
    global float_count
    return float(a) / float(b)  # 计数可加

def lookup_table(idx, table):
    global lookup_count
    lookup_count += 1
    return table[idx]

def reset_stats():
    global shift_count , mul_count, div_count,index_count
    shift_count , mul_count, div_count, index_count= 0, 0, 0, 0

def get_stats():
    return shift_count, mul_count, div_count,index_count
    

